﻿@*
    // Copyright (c) Alex Reich.
    // Licensed under the CC BY 4.0 License.
*@
@page "/New"
@using Newtonsoft.Json
@using RulesEngine.Models
@using RulesEngineEditor.Models
@using System.IO

<RulesEngineEditorPage @ref="ree" EditorRulesEngine="re" @bind-Workflows="Workflows" />

@code {
    private RulesEngine.RulesEngine re;
    RulesEngineEditorPage ree;

    private Workflow[] _workflows;
    private Workflow[] Workflows { get { return _workflows; } set { _workflows = value; } }

    enum FooEnum
    {
        bar = 123
    }

    protected override void OnInitialized()
    {
        var settings = new ReSettings
        {
            CustomTypes = new Type[] { typeof(FooEnum) }
        };
        re = new RulesEngine.RulesEngine(new string[0], settings);

        Workflows = new List<Workflow>().ToArray();
    }
    protected override void OnAfterRender(bool firstRender)
    {
        if (firstRender)
        {
            ree.NewWorkflows();
        }
    }
}